Hệ thống quản lý bệnh viện bằng C# với mã nguồn

1 using System;
2 using
System.Collections.Generic;
3 using
System.ComponentModel;
4 using
System.Data;
5 using
System.Drawing;
6 using
System.Linq;
7 using
System.Text;
8 using
System.Threading.Tasks;
9 using
System.Windows.Forms;
10 using
System.Data.SqlClient;
11
12 namespace
HospitalManagementSystemCSharp
13 {
14     
public partial class RoomInfo : Form
15     {
16         
public RoomInfo()
17         {
18             InitializeComponent();
19         }
20
21         
private void RoomInfo_Load(object sender, EventArgs e)
22         {
23             
// TODO: This line of code loads data into the 'hospitalDataSet2.room' table. You can move, or remove it, as needed.
24             
this.roomTableAdapter.Fill(this.hospitalDataSet2.room);
25             
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=F:\Sem.4\C# Projects\Trials\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
26             {
27
28                 
string str2 = "SELECT * FROM room";
29                 SqlCommand cmd2 =
new SqlCommand(str2, con1);
30                 SqlDataAdapter da =
new SqlDataAdapter(cmd2);
31                 DataTable dt =
new DataTable();
32                 da.Fill(dt);
33                 dataGridView1.DataSource =
new BindingSource(dt, null);
34             }
35         }
36
37         
private void button1_Click(object sender, EventArgs e)
38         {
39             SqlConnection con =
new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=F:\Sem.4\C# Projects\Trials\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
40             con.Open();
41            
42             
try
43             {
44                 
string str = "INSERT INTO room(building,r_type,r_no,no_bed,price,r_status) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "'); ";
45
46                 SqlCommand cmd =
new SqlCommand(str, con);
47                 cmd.ExecuteNonQuery();
48                 
string str1 = "select max(Id) from room;";
49
50                 SqlCommand cmd1 =
new SqlCommand(str1, con);
51                 SqlDataReader dr = cmd1.ExecuteReader();
52                 
if (dr.Read())
53                 {
54                     MessageBox.Show(
"room Information Saved Successfully..");
55                     textBox2.Text =
"";
56                     textBox1.Text =
"";
57                     textBox3.Text =
"";
58                     textBox4.Text =
"";
59                     textBox5.Text =
"";
60                     textBox6.Text =
"";
61                     
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=F:\Sem.4\C# Projects\Trials\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
62                     {
63
64                         
string str2 = "SELECT * FROM room";
65                         SqlCommand cmd2 =
new SqlCommand(str2, con1);
66                         SqlDataAdapter da =
new SqlDataAdapter(cmd2);
67                         DataTable dt =
new DataTable();
68                         da.Fill(dt);
69                         dataGridView1.DataSource =
new BindingSource(dt, null);
70                     }
71                 }
72             }
73             
catch (SqlException excep)
74             {
75                 MessageBox.Show(excep.Message);
76             }
77             con.Close();
78         }
79
80         
private void button2_Click(object sender, EventArgs e)
81         {
82             textBox2.Text =
"";
83             textBox3.Text =
"";
84             textBox4.Text =
"";
85             textBox5.Text =
"";
86             textBox6.Text =
"";
87         }
88     }
89 }


TODO: This line of code loads data into the 'hospitalDataSet2.room' table. You can move, or remove it, as needed.



Gõ tìm kiếm nhanh...